import { i18n } from "boot/i18n";
import { useFunctionsStore } from "stores/functions";

const t = i18n.global.t;
const rs = "routerLinks.settingList."; // 当前文件名加 所在对象名首字母 用于双语
const rd = "routerLinks.deviceFunctions.";
const rse = "routerLinks.serverFunctions."; // 当前文件名加 所在对象名首字母 用于双语

export default function () {
  const {
    mode,
    mobileLinks = [],
    deviceLinks = [],
    serverLinks = [],
  } = useFunctionsStore();
  const linksMap = new Map([
    ["device", deviceLinks],
    ["server", serverLinks],
    ["mobile", mobileLinks],
  ]);
  return routerLinks.filter((item) => {
    // 检索所有路由是否在config中出现，如果出现不论在device还是server或者mobile
    // 都显示出来，如果没有配置进入默认配置路由通过mode字段进行的判断
    // 此方法获得config配置中device,server,mobile,融到成一个数组
    return (
      linksMap.get(mode)?.includes(item.link) ||
      (mode === "remote" ? item.mode === "device" : item.mode === mode) ||
      !item.mode
    );
  });
}

const routerLinks = [
  {
    title: t(rd + "操作面板"),
    caption: t(rd + "主应用界面"),
    icon: "videogame_asset",
    mode: "device",
    link: "DevicePage",
  },
  {
    title: t(rd + "姿态管理"),
    caption: t(rd + "对机器臂相关姿态进行预设"),
    icon: "precision_manufacturing",
    mode: "device",
    link: "PostureIndex",
  },
  {
    title: t(rd + "地图管理"),
    caption: t(rd + "对地图相关进行操作"),
    icon: "route",
    mode: "device",
    link: "MapIndex",
  },
  {
    title: t(rd + "设备控制"),
    caption: t(rd + "查看机器人当前设备状态"),
    icon: "keyboard_hide",
    mode: "device",
    link: "AmrControl",
  },
  {
    title: '任务订单',
    caption: '对运输任务或订单进行管理',
    icon: 'receipt',
    link: 'Task',
    enable: 'enableTask',
  },
  {
    title: t(rse + "远程地图"),
    caption: t(
      rse + "实时查看中控记录的地图信息及设备位置方便同时操控多台设备"
    ),
    icon: "route",
    link: "RosMapRemote",
  },
  {
    title: t(rse + "远程控制"),
    caption: t(rse + "远程操作机器人"),
    icon: "laptop_windows",
    mode: "server",
    link: "RemoteManage",
  },
  {
    title: t(rse + "作业方案"),
    caption: "作业方案",
    icon: "assignment",
    mode: "server",
    link: "ActionPlan",
  },
  {
    title: t(rse + "机床管理"),
    caption: "机床管理",
    icon: "view_module",
    mode: "server",
    link: "ToolManagement",
  },
  {
    title: t(rd + "设备日志"),
    caption: t(rd + "查看本机器人的日志"),
    icon: "text_snippet",
    link: "LogIndex",
  },
  {
    title: t(rd + "设置"),
    caption: t(rd + "参数配置设置"),
    icon: "settings",
    link: "SettingIndex",
  },
];

// 设备端设置
export const settingList = [
  // 服务设置
  {
    label: t(rs + "服务设置"),
    to: "/MicroService",
    iconName: "public",
    iconColor: "blue-6",
    list: [t(rs + "中控IP"), t(rs + "目标IP"), t(rs + "当前网络")],
  },
  // 设备自检
  {
    label: t(rs + "设备自检"),
    to: "/SelfInspection",
    iconName: "build",
    iconColor: "blue-6",
  },
  // 内参标定
  {
    label: t(rs + "内参标定"),
    to: "/SelfCalibrate",
    iconName: "gps_not_fixed",
    iconColor: "blue-6",
  },
  {
    label: t(rs + "工位标定"),
    to: "/StationCalibrate",
    iconName: "view_sidebar",
    iconColor: "blue-6",
  },
  {
    label: t(rs + "夹具标定"),
    to: "/FixtureCalibrate",
    iconName: "amp_stories",
    iconColor: "blue-6",
  },
  {
    label: t(rs + "参数配置"),
    to: "/OsParameter",
    iconName: "list_alt",
    iconColor: "blue-6",
  },
  {
    label: t(rs + "日志上传"),
    to: "/BagUploading",
    iconName: "unarchive",
    iconColor: "blue-6",
    list: [t(rs + "生成文件"), t(rs + "上传文件")],
  },
  {
    label: "换电方案",
    to: "/BatteryScheme",
    iconName: "battery_charging_full",
    iconColor: "blue-6",
  },
];
